package com.yequan.drawerlayoutdemo.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.yequan.drawerlayoutdemo.skin.config.Const;

/**
 * Created by Administrator on 2017/2/13 0013.
 */

public class PrefUtils {
    private Context mContext;

    public PrefUtils(Context mContext) {
        this.mContext = mContext;
    }

    public void savePluginPath(String pluginPath) {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE);
        sp.edit().putString(Const.KEY_PLUGIN_PATH, pluginPath).apply();
    }

    public String getPluginPath() {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        return sp.getString(Const.KEY_PLUGIN_PATH, "");
    }

    public void savePluginPkg(String pluginPkg) {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        sp.edit().putString(Const.KEY_PLUGIN_PKG, pluginPkg).apply();
    }

    public String getPluginPkg() {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        return sp.getString(Const.KEY_PLUGIN_PKG, "");
    }

    public void clear() {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        sp.edit().clear().apply();
    }

    public void saveSuffix(String suffix) {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        sp.edit().putString(Const.KEY_SUFFIX, suffix).apply();
    }


    public String getSuffix() {
        SharedPreferences sp = mContext.getSharedPreferences(Const.PREF_NAME, Context.MODE_APPEND);
        return sp.getString(Const.KEY_SUFFIX, "");
    }
}
